package com.objectproject.main.dao;

import java.util.ArrayList;

import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.objectproject.main.dao.iface.hierarchy.MembershipDAO;
import com.objectproject.main.dao.mybatis.mapper.hierarchy.MembershipMapper;
import com.objectproject.main.model.MyGroup;

@Repository
public class MembershipDAOImpl implements MembershipDAO {

	@Autowired
	SqlSession sqlSession;
	
	
	
	@Override
	public ArrayList<Long> selectGroupIds(long userId) {
		return sqlSession.getMapper(MembershipMapper.class).selectGroupIds(userId);
	}

	@Override
	public ArrayList<MyGroup> selectGroups(long userId) {
		return sqlSession.getMapper(MembershipMapper.class).selectGroups(userId);
	}
	@Override
	public ArrayList<Long> selectMemberIds(long groupId){
		return sqlSession.getMapper(MembershipMapper.class).selectMemberIds(groupId);
	}

	@Override
	public void insertMembership(long userId, long groupId) {
		sqlSession.getMapper(MembershipMapper.class).insertMembership(userId, groupId);
	}

	@Override
	public void deleteMembership(long userId, long groupId) {
		sqlSession.getMapper(MembershipMapper.class).deleteMembership(userId, groupId);
	}

}
